﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../Content/css/bootstrap.min.css" />
    <link rel="stylesheet" href="../Content/css/font-awesome.min.css" />
    <link rel="stylesheet" href="../Content/css/ace.min.css" />
    <link rel="stylesheet" href="../Content/css/jframe.css" />

</head>
<body ng-app="formApp" class="page-content">
    <div ng-controller="formCtrl">
        <form class="form-horizontal" role="form">
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="categoryId">编号</label>
                <div class="col-sm-9">
                    <input type="text" placeholder="编号" class="col-xs-10 col-sm-5" ng-model="code" />
                    <div class="col-sm-12">
                        <div class="help-block">Example block-level help text here.</div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="code">名称</label>
                <div class="col-sm-9">
                    <input type="text" placeholder="名称" class="col-xs-10 col-sm-5" ng-model="name" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="description">描述</label>

                <div class="col-sm-9">
                    <textarea class="col-xs-10 col-sm-5" style="resize:none;" rows="5" id="description" placeholder="描述" ng-model="description"></textarea>
                </div>
            </div>

        </form>

        <div class="center">
            <div class="btn-group ">
                <button class="btn btn-sm btn-purple" ng-click="interactive.onOK()">
                    <i class="icon-save bigger-125"></i>
                    提 交
                </button>
            </div>
            <div class="btn-group">
                <button class="btn btn-sm btn-info" ng-click="interactive.onCancel()">
                    <i class="icon-undo bigger-125"></i>
                    返 回
                </button>
            </div>
        </div>
    </div>
    <script src="../Config.js"></script>
    <script src="../Content/js/jquery-1.10.2/jquery-1.10.2.min.js"></script>
    <script src="../Content/js/bootstrap.min.js"></script>
    <script src="../Content/js/promise/Promise.js"></script>
    <script src="../Content/js/ace-elements.min.js"></script>
    <script src="../Content/js/ace.min.js"></script>
    <script src="../Content/js/bootbox.min.js"></script>
    <script src="../Content/js/angular-1.2.29/angular-1.2.29.min.js"></script>

    <script src="../Content/js/jquery.gritter.min.js"></script>
    <script src="../Content/js/cppei/cppei.view.js"></script>
    <script src="../Content/js/cppei/cppei.paginationPlugin.js"></script>
    <script>
        cppei.install();

        angular.module('formApp', []).controller("formCtrl", function ($scope, $http) {
            $scope.service = {
            };

            $scope.interactive = {
                onCancel: function () {
                    cppei.closeDialog(false, null);
                },
                onOK: function () {
                    $http({
                        method: 'post',
                        url: jframe.getUrl('Api/Model/Create'),
                        cache: false,
                        data: {
                            code: $scope.code,
                            name: $scope.name,
                            description: $scope.description
                        }
                    }).success(function (result, status) {
                        //debugger;
                        if (result.isSuccess) {
                            //创建成功后删除该条信息
                            cppei.growl('创建成功!');
                            cppei.closeDialog(true, null);
                        } else {
                            cppei.growlError(result.message);
                        }
                    }).error(function (result, status) {
                        cppei.growlError(result.message);
                    });
                    //cppei.closeDialog(true, { value: 1 });
                }
            }
        });
    </script>
</body>
</html>
